import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class code2 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] cost = new int[n];
        for(int i=0;i<n;i++) {
            cost[i] = in.nextInt();
        }

        int[] dp = new int[n+1];//从i到楼顶的最小花费

        dp[n-1] = cost[n-1];

        for(int i=n-2;i>=0;i--) {
            dp[i] = Math.min(dp[i+1],dp[i+2])+cost[i];
        }

        System.out.print(Math.min(dp[0],dp[1]));
    }
}